﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySQL.Db;

namespace Gollie.DataTables
{
	public class InactiveVendorsItem
	{
		public ulong BedrijfsId { get; set; }
		public string Bedrijfsnaam { get; set; }
		public ulong ContactPersoonId { get; set; }
		public string UserName { get; set; }
		public string ContactPersoon { get; set; }
		public string Email { get; set; }
		public DateTime Registratiedatum { get; set; }
	}

	public class InactiveVendors : BaseBindable<InactiveVendorsItem>
	{
		public InactiveVendors()
		{
			ResultSet resultSet = Database.Queries.GetInactiveVendors();

			this.AddDetails(resultSet);
		}

		private void AddDetails(ResultSet resultSet)
		{
			int numRows = resultSet.Count;

			for (int i = 0; i < numRows; i++)
			{
				string userName = resultSet.GetString(i, "username");
				UserInfo u = UserInfo.GetUserInfo(userName, false);

				this.Add(new InactiveVendorsItem()
				{
					BedrijfsId = resultSet.GetUInt64(i, "vid"),
					Bedrijfsnaam = resultSet.GetString(i, "vname"),
					ContactPersoonId = resultSet.GetUInt32(i, "uid"),
					UserName = userName,
					ContactPersoon = u.FullName,
					Email = u.Email,
					Registratiedatum = u.RegistratieDatum
				});
			}
		}
	}
}